<?php

namespace bee;
/**
 * 
 * @author dzelenika
 * @todo nije ništa implementirano, samo je kopiran kod klase check
 *
 */
class checkGroup extends widget
{ 
  public $values;
  public $labels;
  public $checks;
  private $events = array(	"onBlurFn", "onClickFn", "onDblClickFn", 
  							"onKeyDownFn", "onKeyPressFn", "onKeyUpFn", 
                            "onMouseDownFn", "onMouseMoveFn", "onMouseOutFn", "onMouseOverFn", "onMouseUpFn");  

  function __construct($name, &$bindValue = "", array $options = array())
  { parent::__construct($name); 
    $this->value = &$bindValue;
    $this->labels = isset($options["labels"]) ? $options["labels"] : array();
    $this->values = isset($options["values"]) ? $options["values"] : array();

    $this->checks = array();
    foreach ($this->values as &$cVal)
    { $nc = new check($name, $cVal);
      $nc->drawMe = false;
      $this->checks[] = $nc;
    }
  }
  
 /** 
  * @param array $evt
  */
  public function onDraw($evt)
  { foreach($this->checks as &$cVal)
    { foreach ($this->events as $evt) 
      { if($this->$evt)
        { $cVal->$evt = clone $this->$evt;
        }
      }
    }
    $this->fillDSDoc();
  }
  
 /** 
  * @param sting $fillVar
  */
  public function fillDSDoc($fillVar = "")
  { if($fillVar)
    { $this->DSDoc->setVariable($fillVar, $this->value);
    }
    $this->DSDoc->setObject("widgets/" . $this->name, $this);
  }
}
